package cn.tedu.baking.service.impl;

import cn.tedu.baking.mapper.ICommentMapper;
import cn.tedu.baking.pojo.dto.CommentSaveDTO;
import cn.tedu.baking.pojo.entity.Comment;
import cn.tedu.baking.pojo.vo.CommentVO;
import cn.tedu.baking.service.ICommentService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * Author：毕龙
 * Date: 2024/8/17 15:54
 */
@Service
public class CommentServiceImpl implements ICommentService {

    @Autowired
    private ICommentMapper iCommentMapper;

    @Override
    public List<CommentVO> getCommentsByContentId(Integer id) {
        return iCommentMapper.getCommentsByContentId(id);
    }

    @Override
    public void saveCommentsByContentId(CommentSaveDTO commentSaveDTO) {
        Comment comment = new Comment();
        BeanUtils.copyProperties(commentSaveDTO, comment);
        comment.setCreateTime(new Date());
        iCommentMapper.saveCommentsByContentId(comment);
    }
}
